package com.yanghui.agent.attachMain;

import com.sun.tools.attach.VirtualMachine;

public class AttachMain {

    /**
     * 加载agent程序，动态附着到指定jvm上去
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        VirtualMachine vm = VirtualMachine.attach("29226");
        vm.loadAgent("/Users/yanghui/workspace3/agent-tutorial/agent-attach/target/agent-attach.jar", "key1=value1");
        vm.detach();
        System.out.println("附着完毕！");
    }
}
